package com.hc.controller;

import com.hc.entity.Manager;
import com.hc.entity.Role;
import com.hc.service.ManagerService;
import com.hc.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/mmm")
public class ManagerController {

	@Autowired
	private ManagerService managerService ;

	@Autowired
    private RoleService roleService;

	@RequestMapping("/list")
	public ModelAndView list(ModelAndView mav) {
        System.out.println("list");
		return mav;
	}

	@RequestMapping("/detail")
	public ModelAndView detail(ModelAndView mav, Integer id) {

		Manager manager = managerService.getManagerById(id);
		mav.setViewName("manager_detail");
		mav.addObject("manager",manager);

		//查询role_id所对应的role name
        Role role = roleService.getRoleById(manager.getRoleId());
        mav.addObject("role",role);

        return mav;
	}

	@RequestMapping("/add")
	public ModelAndView add(ModelAndView mav) {
		return mav;
	}

	@RequestMapping("/update")
	public ModelAndView update(ModelAndView mav) {
		return mav;
	}

	@RequestMapping("/delete")
	public ModelAndView delete(ModelAndView mav, Integer id) {
		return mav;
	}

}
